package com.yanshibo.house01_dao.dao;

import java.util.List;

import javax.validation.Valid;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.yanshibo.house01_bean.bean.Hourse;
import com.yanshibo.house01_bean.bean.Lei;
import com.yanshibo.house01_bean.bean.PeiTao;
import com.yanshibo.house01_bean.bean.Tem;



//dao层
@Repository
public interface MyDao {

	//列表
	List<Hourse> list(Tem tem);

	//出租
	@Update("update hourse set status='1',rental_time=now() where id=#{id}")
	void chu(String id);

	//退租
	@Update("update hourse set status='0',listing_time=now(),rental_time=null where id=#{id}")
	void tui(String id);

	// 删除
	@Delete("delete from hourse where id=#{id}")
	void del(String id);

	//房屋类型
	@Select("select * from lei")
	List<Lei> listLei();

	//添加房屋信息
	@Insert("insert into hourse set name=#{name},building=#{building},number=#{number},picture=#{picture},status=#{status},listing_time=#{listingTime},type_id=#{typeId},type=#{typ.ordinal}")
	void addHou(@Valid Hourse hou);

	//查询房屋信息
	@Select("select * from hourse where id = #{id}")
	Hourse listHou(Integer id);

	//添加配套设施
	@Insert("insert into houpei set r_id=#{hid},s_id=#{id},num=#{num}")
	void addPei(@Valid PeiTao pei);

	//查询配套设施
	@Select("select * from peiTao where name=#{name}")
	PeiTao seletePei(@Valid PeiTao pei);


}
